Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] Add 'create_doc' index privilege (#45806) #47645

Merged
merged 1 commit into from
Oct 7, 2019

Conversation

bizybot
Copy link
Contributor

@bizybot bizybot commented Oct 7, 2019

Use case:
User with create_doc index privilege will be allowed to only index new documents
either via Index API or Bulk API.

There are two cases that we need to think:

  • User indexing a new document without specifying an Id.
    For this ES auto generates an Id and now ES version 7.5.0 onwards defaults to op_type create we just need to authorize on the op_type.
  • User indexing a new document with an Id.
    This is problematic as we do not know whether a document with Id exists or not.
    If the op_type is create then we can assume the user is trying to add a document, if it exists it is going to throw an error from the index engine.

Given these both cases, we can safely authorize based on the op_type value. If the value is create then the user with create_doc privilege is authorized to index new documents.

In the AuthorizationService when authorizing a bulk request, we check the implied action.
This code changes that to append the :op_type/index or :op_type/create
to indicate the implied index action.

Use case:
User with `create_doc` index privilege will be allowed to only index new documents
either via Index API or Bulk API.

There are two cases that we need to think:
- **User indexing a new document without specifying an Id.**
   For this ES auto generates an Id and now ES version 7.5.0 onwards defaults to `op_type` `create` we just need to authorize on the `op_type`.
- **User indexing a new document with an Id.**
   This is problematic as we do not know whether a document with Id exists or not.
   If the `op_type` is `create` then we can assume the user is trying to add a document, if it exists it is going to throw an error from the index engine.

Given these both cases, we can safely authorize based on the `op_type` value. If the value is `create` then the user with `create_doc` privilege is authorized to index new documents.

In the `AuthorizationService` when authorizing a bulk request, we check the implied action.
This code changes that to append the `:op_type/index` or `:op_type/create`
to indicate the implied index action.
@bizybot bizybot merged commit b6d1d2e into elastic:7.x Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant